#include "stdafx.h"
#include "RectBase.h"



RectBase::RectBase()
:m_nPosX(0)
,m_nPosY(0)
,m_nWidth(0)
,m_nHeight(0)
,m_fTexLeft(0)
,m_fTexRight(1.f)
,m_fTexTop(0)
,m_fTexBottom(1.f)
,m_bShow(TRUE)
{

}

RectBase::~RectBase()
{}

void RectBase::SetPos(int nPosX, int nPosY)
{
	m_nPosX = nPosX;
	m_nPosY = nPosY;
	ChangeSize();
}

void RectBase::SetSize(int nWidth, int nHeight)
{
	m_nWidth = nWidth;
	m_nHeight = nHeight;
	ChangeSize();
}

void RectBase::SetPosSize(int nPosX, int nPosY, int nWidth, int nHeight)
{
	m_nPosX = nPosX;
	m_nPosY = nPosY;
	m_nWidth = nWidth;
	m_nHeight = nHeight;
	ChangeSize();
}

void RectBase::SetTexPos(float fL, float fR, float fT, float fB)
{
	m_fTexLeft = fL;
	m_fTexRight = fR;
	m_fTexTop = fT;
	m_fTexBottom = fB;
	ChangeSize();
}

BOOL RectBase::PtInRect(int nPosX, int nPosY)
{
	if( IsShow() == FALSE ) return FALSE;

	RECT rc = { m_nPosX, m_nPosY, m_nPosX + m_nWidth, m_nPosY + m_nHeight};
	POINT pt = {nPosX, nPosY};
	return ::PtInRect(&rc, pt);
}